package ar.com.personalTravellers.internationalization.context;

import com.angel.arquitectura.dao.language.LanguageDAO;
import com.angel.arquitectura.model.internationalization.Language;
import com.angel.resourceBundle.context.ResourceBundleContext;
import com.angel.resourceBundle.propertyValue.PropertyValue;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Collection;

public class SGSimpleResourceBundleContext extends ResourceBundleContext {

    private static final String APPLICATION_CONTEXT_KEY = "SGPT";
    private static final String RESOURCE_BUNDLE_MANAGER_TYPE = "SIMPLE";

    private Collection<Language> languages;

    private String currentLanguageName;

    @Autowired
    private LanguageDAO languageDAO;

    public SGSimpleResourceBundleContext(){
		super();
        this.languages = new ArrayList<Language>();
    }

    public String getApplicationKey() {
        return APPLICATION_CONTEXT_KEY;
    }

    @Override
	public String getCurrentLanguageName() {
		return this.currentLanguageName;
	}

    public String getResourceBundleManagerType() {
        return RESOURCE_BUNDLE_MANAGER_TYPE;
    }

    public void initializeContext() {
        Collection<Language> languajes = this.getLanguageDAO().findAll();
        this.languages.addAll(languajes);
    }

    public void updatePropertyValue(PropertyValue propertyValue) {
        //Do nothing.
    }

    public Collection<Language> getLanguages() {
        return languages;
    }

    public void setLanguages(Collection<Language> languages) {
        this.languages = languages;
    }

    public LanguageDAO getLanguageDAO() {
        return languageDAO;
    }

    public void setLanguageDAO(LanguageDAO languageDAO) {
        this.languageDAO = languageDAO;
    }
}